package com.stylefeng.guns.shiro;

import org.apache.shiro.codec.Base64;
import org.apache.shiro.crypto.hash.Md5Hash;

public class Md5 {
    //  MD5(password+sort)加解密
    private static final String PASSWORD = "admin";
    private static final String PWD = "YWRtaW4=";
    private static final String SALT = "8pgby";

    private static String encBase64(String str) {
        return Base64.encodeToString(str.getBytes());
    }
    private static String decBase64(String str){
        return Base64.decodeToString(str);
    }
    private static String md5(String str,String salt){
        return new Md5Hash(str,salt).toString();
    }

    public static void main(String[] args) {
        System.out.println(Md5.encBase64(PASSWORD));
        System.out.println(Md5.decBase64(PWD));
        System.out.println(Md5.md5(PASSWORD, SALT));
    }

}
